





package com.lanou3g.springcloud.consumer.hystrix.web;

import com.lanou3g.springcloud.consumer.hystrix.client.HelloClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Eureka服务注册中心常规调用方式
 */
@Slf4j
@Controller
@RequestMapping("/feign")
public class HelloFeignController {

	@Autowired
	private HelloClient helloClient;

	@RequestMapping("/")
	public String defaultHello(Model model) {
		String result = helloClient.hello();
		model.addAttribute("msg", result);
		return "index";
	}

	@RequestMapping("/name/{name}")
	public String nameHello(@PathVariable String name, Model model) {
		String result = helloClient.helloName(name);
		model.addAttribute("msg", result);
		return "index";
	}

	@RequestMapping("/json/{name}")
	public String jsonHello(@PathVariable String name, Model model) {
		String result = helloClient.helloJson(name);
		model.addAttribute("msg", result);
		return "index";
	}
}